package ClassWork5;

// 财务部门类
public class FinanceDept extends Dept {
    public FinanceDept(String deptName) {
        super(deptName);
    }

    public void processPayroll() {
        System.out.println("Processing payroll in " + getDeptName());
    }

    // 输出单人工资条方法
    public void printIndividualPayroll(Employee employee) {
        System.out.println("单人工资条:");
        System.out.println("姓名: " + employee.getName());
        System.out.println("编号: " + employee.getId());
        System.out.println("工资: " + employee.getSalary());
        System.out.println("额外收入: " + companyGetExtraIncome(employee));
    }

    // 获取员工额外收入（年度奖金或小时费率）
    private double companyGetExtraIncome(Employee employee) {
        if (employee instanceof FullTimeEmployee) {
            FullTimeEmployee fullTimeEmployee = (FullTimeEmployee) employee;
            return fullTimeEmployee.getAnnualBonus();
        } else if (employee instanceof PartTimeEmployee) {
            PartTimeEmployee partTimeEmployee = (PartTimeEmployee) employee;
            return partTimeEmployee.getHourlyRate();
        }
        return 0;
    }

    // 员工加薪方法
    public void raiseSalary(Employee employee, double amount) {
        double currentSalary = employee.getSalary();
        employee.setSalary(currentSalary + amount);
        System.out.println(employee.getName() + " 的工资已增加 " + amount + "，新工资为 " + employee.getSalary());
    }

    // 员工减薪方法
    public void cutSalary(Employee employee, double amount) {
        double currentSalary = employee.getSalary();
        if (currentSalary >= amount) {
            employee.setSalary(currentSalary - amount);
            System.out.println(employee.getName() + " 的工资已减少 " + amount + "，新工资为 " + employee.getSalary());
        } else {
            System.out.println("减薪金额不能超过当前工资，操作未执行。");
        }
    }
}
